# Contributor: Taner Tas <taner76@gmail.com>
# Maintainer: Taner Tas <taner76@gmail.com>
pkgname=emulationstation
_pkgname="EmulationStation"
pkgver=2.10.3
pkgrel=2
pkgdesc="EmulationStation is a cross-platform graphical front-end for emulators with controller navigation."
url="https://github.com/RetroPie/EmulationStation"
arch="all !armhf !s390x !riscv64" # vlc-dev
license="MIT"
makedepends="boost-dev freeimage-dev freetype-dev sdl2-dev mesa-dev alsa-lib-dev vlc-dev curl-dev cmake rapidjson-dev"
_theme_name="gbz35"
_theme_commit="05895874b2920ab6ffeeb574d053f3d9e976c000"
_pugixml_ver="1.11.1"
subpackages="$pkgname-theme-$_theme_name:theme:noarch"
options="!check" # No test suite

source="$pkgname-$pkgver.tar.gz::https://github.com/RetroPie/$_pkgname/archive/v$pkgver.tar.gz
	$pkgname-theme-$_theme_name-$_theme_commit.tar.gz::https://github.com/rxbrad/es-theme-$_theme_name/archive/$_theme_commit.tar.gz
	pugixml-$_pugixml_ver.tar.gz::https://github.com/zeux/pugixml/archive/v$_pugixml_ver.tar.gz
	default-paths.patch
	emulationstation.desktop
	emulationstation.png"
builddir="$srcdir"/$_pkgname-$pkgver

prepare() {
	if [ ! -d external/pugixml.dist ]; then
		mv -f external/pugixml external/pugixml.dist
		cp -aP "$srcdir"/pugixml-$_pugixml_ver external/pugixml
	fi
	default_prepare
}

build() {
	cmake .
	make
}

package() {
	depends="$pkgname-theme-default"
	mkdir -p "$pkgdir"/usr/bin
	mkdir -p "$pkgdir"/usr/share/pixmaps
	mkdir -p "$pkgdir"/usr/share/applications
	mkdir -p "$pkgdir"/usr/share/$pkgname/gamelists
	mkdir -p "$pkgdir"/usr/share/$pkgname/themes
	install -Dm755 emulationstation "$pkgdir"/usr/bin/emulationstation
	install -Dm644 "$srcdir"/$pkgname.png "$pkgdir"/usr/share/pixmaps/
	install -Dm644 "$srcdir"/$pkgname.desktop "$pkgdir"/usr/share/applications/
}

theme() {
	pkgdesc="$_theme_name theme for $_pkgname"
	license="CC-BY-NC-SA-3.0"
	url="https://github.com/rxbrad/es-theme-gbz35"
	provides="$pkgname-theme-default"

	install -d -m755 "$subpkgdir"/usr/share/$pkgname/themes
	cp -r "$srcdir"/es-theme-$_theme_name-$_theme_commit \
		"$subpkgdir"/usr/share/$pkgname/themes/$_theme_name
}
sha512sums="
36df98dae25b52f15c235c8e168ef758f5a6433e0000b1d4016494a0733723931ff7ef9a0558fef4f235842324fa70e41d83a5403f44bcc138cd013c2f28e8ac  emulationstation-2.10.3.tar.gz
23e764e41a8ca359657508f5103c841e25d6403ddaafa9ca2f55379e42a17541d85cacac9d18fa9316d17450cd6bd6b8ae345f07165971b2a02e03b8e33bf35c  emulationstation-theme-gbz35-05895874b2920ab6ffeeb574d053f3d9e976c000.tar.gz
94a79a28d96e763cdd8951c4d0b20aefb43cd1b32cbf5a5354b09f2636710e960e2dbfa56534b61c8d6ddecb2126a006e5f485c1465a97376e1cc077df25f16e  pugixml-1.11.1.tar.gz
f97954e411078507b312b9859ff300bf2018945dedc2be593103a0aca1b0bd233a173ab6f74c983735bf0bbc0600b49ba6987b60c03ed697c1328f906c154799  default-paths.patch
814a196d234266809f2c3f64c7179e3138e017eb67d1c54dcc2e8c504c1439cb73f17352575cd582ce044b08405f3a369d049127c9f4c5a1336072435dfa54f0  emulationstation.desktop
4a24c435aeef22d7d69c3af113bff97c2c99b4a1eb2e5c97f53a6cce1f11a4f92bf4250388598a89f8fd462e03ea6fc73b75739573faf6f7b30c98ab53ddb5bf  emulationstation.png
"
